<?php
namespace app\admin\behavior;
use think\Controller;
use think\Session;

//this->error 函数需要用得Controller 所以判断登录 应该用继承的方法
class LoginCheck extends Controller
{
    public function moduleInit($request)
    {
         if($request->module() == 'admin' ){
             if($request -> controller() != 'Login'){
                
         		if(!Session::get('admin_user')){
                   $this->error("请先登录",'/index.php?s=/admin/login/index');
                }
             }
         }
       
    }
    
    public function adminBegin()
    {
       echo 'aaa';
    }

}
